package com.dynamicapp

import android.Manifest
import android.os.Bundle
import android.os.Environment
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import com.dynamicapp.plugin.ProxyActivity
import java.io.File

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        ActivityCompat.requestPermissions(this,
            arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE), 100)
    }

    fun startApk(view: View?) {
        val dir = Environment.getExternalStorageDirectory().path + "/000mytest"
        File(dir).apply {
            if (!exists()) {
                mkdir()
            }
        }


        val path = "$dir/otherapk-debug.apk"
        ProxyActivity.launch(this, path)
    }
}